#ifndef TOURNAMENTSELECTION_H_
#define TOURNAMENTSELECTION_H_

#include <vector>
#include "../Selection.h"
#include "../../Solution/Solution.h"

/** Implementation of tournament style selection.
 * 
 *    In tournament style selection, a tournament size N is provided to the selector.
 *  When a selection is performed, N solutions are selected at random from the genepool,
 *  and the solution with the highest fitness is returned.
 * 
 *    Since select() is expected to return two solutions, two tournaments are 
 *  held for each call to select().   
 */

class TournamentSelection : public Selection
{
    public:
        TournamentSelection();
        TournamentSelection(unsigned int tournamentSize);
        void setTournamentSize(unsigned int newSize);
        void select(Solution* &, Solution* &);            /**< Abstract selection function */
        void prepare(vector<Solution*>);                  /**< Abstract prepare function   */
        
        static Selection* getSelection();
        static Selection* getSelection(unsigned int tournamentSize);
    protected:
        void clean();                                     /**< cleans function     */
        vector<Solution*> genePool;
    private:
        unsigned int tournamentSize;
        vector<Solution*> tournamentContainer;
};

#endif /*TOURNAMENTSELECTION_H_*/
